package com.xb.loan.cashier.biz.job;

import com.xb.loan.cashier.biz.task.TaskManagerFactory;
import com.xb.loan.cashier.biz.task.plat.PlatAccountChargeTask;
import com.xb.loan.cashier.service.constant.ICashierEnumConst;
import com.xb.loan.util.DateHelper;
import com.xb.loan.util.StringUtils;
import com.xb.loan.util.qrtz.task.AbstractCronTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
 * 平台充值对账定时任务
 */
public class PlatAccountChargeJob extends AbstractCronTask {
    
    private static final Logger log = LoggerFactory.getLogger(PlatAccountChargeJob.class);
    
    @Override
    public void run() {
        Date date = DateHelper.getBeforeDay(new Date(), -1);
        String accountPeriod = DateHelper.formatDate("yyyyMMdd", date);
        if (StringUtils.isEmpty(accountPeriod)) {
            log.info("run 账期为空,已退出!");
            return;
        }
        PlatAccountChargeTask pact = getSpringBean("platAccountChargeTask");
        pact.setAccountPeriod(accountPeriod);
        
        TaskManagerFactory.getTaskManager(ICashierEnumConst.TaskManagerCode.ACCTONT).addTask(pact);
        
        log.info("run 当前账期："+accountPeriod+"已启动充值对账任务");
    }
}
